﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MathDrawDll;

namespace _1101曲线绘制
{
    public partial class Form1 : Form
    {
        //用户选择的曲线的索引
        //  0 -- y=x  1 -- y = x^2 ......
        int selectedCurve = -1;
        public Form1()
        {
            InitializeComponent();
			pictureBox1.BorderStyle = BorderStyle.FixedSingle;
			listBox1.Items.Add("y = x");            //0
			listBox1.Items.Add("y = x ^ 2");        //1
			listBox1.Items.Add("y = x ^ 3");        //2
			listBox1.Items.Add("y = 1 / x");        //3
			listBox1.Items.Add("y = log 2 (x)");    //4
			listBox1.Items.Add("y = ln (x)");       //5
			listBox1.Items.Add("y=e(x),y=e(-x)");   //6
			listBox1.Items.Add("y = sin(x)");       //7
			listBox1.Items.Add("y = tan(x)");       //8
			listBox1.Items.Add("y =6*e(-ax)*sin(x)");//9
			listBox1.Items.Add("y =Sa(x)= sin(x)/x");//10
			listBox1.Items.Add("心形线 1");        //11
			listBox1.Items.Add("心形线 2");        //12
			listBox1.Items.Add("心形线 3");        //13
			listBox1.Items.Add("Ax^2+Bx+C");        //14
			listBox1.Items.Add("螺旋线");        //15

		}

		private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
			MathDrawClass mdc = new MathDrawClass(e.Graphics, pictureBox1.ClientRectangle);
			mdc.DrawFrame();
			int a, b, c;
			a = b = c = 0;
			switch (selectedCurve)
			{
				case 0: mdc.DrawYEX(); break;
				case 1: mdc.DrawYEX2(); break;
				case 2: mdc.DrawYEX3(); break;
				case 3: mdc.DrawYEXReciprocal(); break;
				case 4: mdc.DrawLog2(); break;
				case 5: mdc.DrawLoge(); break;
				case 6: mdc.DrawExp(); break;
				case 7: mdc.DrawSin(); break;
				case 8: mdc.Drawtan(); break;
				case 9: mdc.DrawExpSin(); break;
				case 10: mdc.DrawSa(); break;
				case 11: mdc.DrawHeartLine1(); break;
				case 12: mdc.DrawHeartLine2(); break;
				case 13: mdc.DrawHeartLine3(); break;
				case 14:
					Form2 from2 = new Form2();
					if (from2.ShowDialog() == DialogResult.OK)
						mdc.Draw14(Form2.a, Form2.b, Form2.c);
					break;
				case 15:
						mdc.Draw15(1f);
					break;
					

			}
		}

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
			if (listBox1.SelectedIndex == -1) return;
			selectedCurve = listBox1.SelectedIndex;
			pictureBox1.Refresh();
		}
    }
}
